home *** CD-ROM | disk | FTP | other *** search
- ;void horizontal_line(hrz_char,left_col,left_row,width);
- ; unsigned char hrz_char,left_col,left_row,width;
-
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _horizontal_line
- _horizontal_line proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov ax,_video_buffer ;fetch _video_buffer
- mov es,ax ;ES pts to screen
- sub ax,ax ;
- mov al,[bp+8] ;get row
- dec ax ;count from 0
- mov dl,160 ;bytes in a row
- mul dl ;times rows
- sub dx,dx ;
- mov dl,[bp+6] ;get column
- dec dx ;count from 0
- shl dx,1 ;double for attributes
- add ax,dx ;add to row offset
- mov di,ax ;ES:DI pts to first char
- mov cl,[bp+10] ;width in CL
- cmp cl,1 ;test for 0 and 1
- jnbe A2 ;jump if OK
- jmp L2 ;else quit
- A2: sub cl,2 ;subtract 2 for end chars
- mov al,[bp+4] ;ln thickness code in AL
- mov ch,0c4h ;assume single horz line
- mov dx,0d8ceh ;center chars for dbl ln
- mov bl,0bah ;dbl vert char to BL
- cmp al,'D' ;double line?
- je B2 ;jump ahead if so
- cmp al,'d' ;double line?
- je B2 ;jump ahead if so
- jmp short D2 ;else skip over dbl code
- B2: mov ch,0CDh ;dbl horz char to CH
- mov si,0b5b9h ;chars for other end
- mov [bp+10],si ;save on stack
- mov al,0ffh ;flag to fetch char
- call Writeit ;write the character
- cmp al,bl ;double vertical char?
- jne C2 ;jump ahead if not
- mov al,0CCh ;char for double,double
- jmp short F2 ;ready to go, jump ahead
- C2: mov al,0c6h ;char for double,single
- jmp short F2 ;ready to go, jump ahead
- D2: mov dx,0c5d7h ;center chars for dbl ln
- mov si,0b4b6h ;chars for other end
- mov [bp+10],si ;save on stack
- mov al,0ffh ;flag to fetch char
- call Writeit ;write the character
- cmp al,bl ;double vertical char?
- jne E2 ;jump ahead if not
- mov al,0c7h ;char for single,double
- jmp short F2 ;ready to go, jump ahead
- E2: mov al,0c3h ;char for single,single
- F2: mov ah,al ;save char in AH
- mov al,0ffh ;flag to fetch char
- inc di ;scrn ptr to attribute
- call Writeit ;write the character
- dec di ;pull back pointer
- xchg ah,al ;AH-attri, AL-char
- call Writeit ;write the character
- mov bx,0b3bah ;vertical chars in BX
- or cl,cl ;any straight chars?
- jz K2 ;jump ahead if not
- mov al,ch ;horizontal char to AL
- G2: mov al,0ffh ;flag to fetch char
- call Writeit ;write the character
- cmp al,bl ;double vertical char?
- je I2 ;jump ahead if so
- mov al,0ffh ;flag to fetch char
- call Writeit ;write the character
- cmp al,bh ;single verticle char?
- je H2 ;jump ahead if so
- mov al,ch ;else single line char
- jmp short J2 ;go write it
- H2: mov al,dh ;single center char to AL
- jmp short J2 ;go print it
- I2: mov al,dl ;double center char to AL
- J2: call Writeit ;write the character
- mov al,ch ;restore horizontal char
- jcxz L2 ;quit if CH cleared below
- dec cl ;decrement counter
- jnz G2 ;loop until 0
- K2: mov dx,[bp+10] ;end chars to DX
- sub ch,ch ;clear CH
- jmp short G2 ;go write end char
- L2: sti ;reenable interrupts
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _horizontal_line endp
- Writeit PROC
- push dx ;save DX
- push bx ;BX too
- cld ;set direction flag
- cmp al,0FFh ;FF=return video char
- je D1 ;jump, return char in AL
- mov dx,es ;ES pts to video buffer
- cmp _snow_protect,0 ;protect against snow?
- je C1 ;jump ahead if so
- mov dx,3dah ;status byte address
- mov bx,ax ;save contents of AX
- A1: in al,dx ;get status byte
- test al,1 ;test bit
- jnz A1 ;loop till 0
- cli ;disable interrupts
- B1: in al,dx ;get status byte
- test al,1 ;test bit
- jz B1 ;loop till 1
- mov ax,bx ;return character to AX
- C1: stosw ;write the character
- jmp short H1 ;jump ahead
- D1: mov dx,es ;ES pts to video buffer
- cmp dx,0b800h ;test for graphics card
- jb G1 ;jump if not graphics
- mov dx,3dah ;status byte address
- E1: in al,dx ;get status byte
- test al,1 ;test bit
- jnz E1 ;loop till 0
- cli ;disable interrupts
- F1: in al,dx ;get status byte
- test al,1 ;test bit
- jz F1 ;loop till 1
- G1: mov al,es:[di] ;get char for return
- H1: pop bx ;restore BX
- pop dx ;restore DX and return
- ret ;
- WriteIt endp
- _TEXT ENDS
- END